<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>oa</title>
    <link rel="stylesheet" href="/resources/layui/css/layui.css"/>
</head>
<body>


<form class="layui-form edit-form" action="" style="margin-top: 20px;margin-right: 40px;">
    <div class="layui-form-item">
        <label class="layui-form-label">员工姓名</label>
        <div class="layui-input-block">
            <input type="hidden" id="employeeId" name="employeeId" value="">
            <input type="text" id="empName" name="empName" required  lay-verify="required" placeholder="请输入姓名" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">职位</label>
        <div class="layui-input-block">
            <input type="text"  id="title" name="title" required  lay-verify="required" placeholder="请输入职位" autocomplete="off" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">部门</label>
        <div class="layui-input-block">
            <select name="dept" lay-verify="required">
                <option value=""></option>
                <option value="2">研发部</option>
                <option value="3">市场部</option>
            </select>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">职级</label>
        <div class="layui-input-inline">
            <input type="text"  id="level" name="level" required lay-verify="required" placeholder="请输入职级" autocomplete="off" class="layui-input">
        </div>
        <div class="layui-form-mid layui-word-aux">7为部门经理,7以下为普通员工</div>
    </div>


    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit lay-filter="sub">立即提交</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>
</form>


<script src="/resources/layui/layui.js"></script>
<script src="/resources/sweetalert2.all.min.js"></script>
<script>
    var $ = layui.$; //jQuery对象
    var index = parent.layer.getFrameIndex(window.name);
    layui.form.on('submit(sub)', function(data){
        console.info("向服务器提交的表单数据",data.field);
        $.post("/emp/edit",data.field,function (json) {
            console.info(json);
            if(json.code == "0"){

                parent.layer.close(index);
                window.location.href="/forward/list";
            }else{
            }
        },"json");//告诉jquery 服务器返回的是json
        return false;
    });
</script>
</body>
</html>